const { Menu, MenuItem } = require("@electron/remote");

window.addEventListener("DOMContentLoaded", () => {
  const menuItem = new Menu();
  
  createBtn.addEventListener("click", () => {
    const menuFile = new MenuItem({ label: "文件", type: "normal" });
    const menuEdit = new MenuItem({ label: "编辑", type: "normal" });
    const customMenu = new MenuItem({ label: "自定义菜单项", submenu: menuItem });

    const menu = new Menu();
    menu.append(menuFile);
    menu.append(menuEdit);
    menu.append(customMenu);

    Menu.setApplicationMenu(menu);
  });

  addBtn.addEventListener("click", () => {
    let text = input.value.trim();
    if (!text) return;
    menuItem.append(new MenuItem({ label: text, type: "normal" }));
    input.value = "";
  });
});